package org.softmed.rest.generation.xml.manager;

import java.util.HashMap;
import java.util.Map;
import org.softmed.persistence.PersistenceManager;
import org.softmed.rest.config.Application;
import org.softmed.rest.generation.xml.XMLUnmarshaller;

public class RecoverExistingObjectsUnmarshaller {

	static Map<String, XMLUnmarshaller> unmarshallers = new HashMap<String, XMLUnmarshaller>();

	XMLUnmarshaller unmarshaller;

	public RecoverExistingObjectsUnmarshaller(String choice) {
		unmarshaller = unmarshallers.get(choice);
		if (unmarshaller != null)
			unmarshaller = unmarshaller.clone();
	}

	public Object fromXML(Class type, String xml, PersistenceManager util,
			Application app) throws Throwable {
		return unmarshaller.fromXML(xml, type, util, app);
	}

	public static Map<String, XMLUnmarshaller> getUnmarshallers() {
		return unmarshallers;
	}

}
